{include file='head'/}
<body>
<form class="layui-form" action="">
    <div class="mainBox">
        <div class="main-container">
            <div class="layui-form-item">
                <label class="layui-form-label">用户名</label>
                <div class="layui-input-block">
                    <input type="text" name="username" lay-verify="required" autocomplete="off"
                           placeholder="请输入用户名"
                           class="layui-input readonly_bg" value="{$data.username}" readonly="readonly">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">昵称</label>
                <div class="layui-input-block">
                    <input type="text" name="nickname" lay-verify="required" autocomplete="off" placeholder="请输入昵称"
                           class="layui-input" value="{$data.nickname}">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">邮箱</label>
                <div class="layui-input-block">
                    <input type="text" name="email" lay-verify="email" autocomplete="off" placeholder="请输入邮箱"
                           class="layui-input" value="{$data.email}">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">密码</label>
                <div class="layui-input-block">
                    <input type="password" name="password" autocomplete="off"
                           placeholder="如果为空，则不更改密码"
                           class="layui-input">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">确认密码</label>
                <div class="layui-input-block">
                    <input type="password" name="password2" autocomplete="off"
                           placeholder="请重新输入密码"
                           class="layui-input">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">角色组</label>
                <div class="layui-inline">
                    <select name="role_id">
                        {foreach $role_group_name as $key=>$v}
                        <option value="{$key}" {if ($data.role_id eq $key)}selected{
                        /if}>{$v}</option>
                        {/foreach}
                    </select>
                </div>
            </div>
            <div class="layui-form-item huicmf-upload">
                <label class="layui-form-label">头像</label>
                <div class="layui-input-inline" style="width: 50%">
                    <input type="text" name="avatar" value="{$data.avatar}"
                           onmouseover="hui_img_preview('avatar-select-input',this.value)"
                           onmouseout="layer.closeAll();" id="avatar-select-input" autocomplete="off"
                           class="layui-input">
                </div>
                <div class="layui-input-inline" style="width: 120px">
                    <a class="layui-btn"
                       data-open-pic="{:__url('index/file_list',['type'=>'one','select_id'=>'avatar-select-input'])}">
                        <i class="layui-icon">&#xe67c;</i>选择图片
                    </a>
                </div>
                <ul class="huicmf-upload-preview  clearfix "></ul>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">状态</label>
                <div class="layui-input-block">
                    <input type="radio" name="status" value="1" title="启用" {if ($data.status eq 1)}checked{/if}>
                    <input type="radio" name="status" value="0" title="禁用" {if ($data.status eq 0)}checked{/if}>
                </div>
            </div>
        </div>
    </div>
    <input type="hidden" name="id" id="id" value="{$data.id}">
    <div class="bottom">
        <div class="button-container">
            <button type="submit" class="pear-btn pear-btn-primary pear-btn-sm" lay-submit=""
                    lay-filter="admin-save">
                <i class="layui-icon layui-icon-ok"></i>
                提交
            </button>
            <button type="reset" class="pear-btn pear-btn-sm">
                <i class="layui-icon layui-icon-refresh"></i>
                重置
            </button>
        </div>
    </div>
</form>

{include file='footer'/}
<script>
  layui.use(['form', 'jquery'], function () {
    let form = layui.form;
    let $ = layui.jquery;
    form.on('submit(admin-save)', function (data) {
      $.ajax({
        url: "{:__url('system/admin/edit')}",
        data: JSON.stringify(data.field),
        dataType: 'json',
        contentType: 'application/json',
        type: 'post',
        success: function (res) {
          if (res.code === 200) {
            hui_msg(res.msg, 1, function () {
              window.location.reload();
            });
          } else {
            hui_msg(res.msg, 2);
          }
        }
      })
      return false;
    });
  })
</script>
<script>
</script>
</body>
</html>
